package cn.itcast.nems.studentrecord.dto;

import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Objects;

/**
 * <p>
 * 班级变更开班时间DTO
 * </p>
 *
 * @author zhouwei
 * @since 2023/12/26 3:08 PM
 **/
@Data
@NoArgsConstructor
public class StudentRecordChangeWithClazzStartDateDTO implements Serializable {
    /**
     * 学籍ID
     */
    private String studentRecordId ;
    /**
     * 班级ID
     */
    private Integer clazzId ;
    /**
     * 班级名称
     */
    private String  clazzName ;
    /**
     * 班级修改前开班时间
     */
    private LocalDateTime beforeDate ;
    /**
     * 班级修改后开班时间
     */
    private LocalDateTime afterDate ;
    /**
     * 原学籍-进班时间
     */
    private LocalDateTime inDate ;
    /**
     * 原学籍-出班时间 ,对应  班级 结课时间  (表：e2_clazz 字段: graduation_date)
     */
    private LocalDateTime outDate ;
    /**
     * 实际应付金额
     */
    private Integer actualAmountDue;

    public static StudentRecordChangeWithClazzStartDateDTO buildApiParam(String studentRecordId,
                                                                         Integer clazzId,
                                                                         String clazzName,
                                                                         LocalDateTime afterDate ,
                                                                         LocalDateTime inDate,
                                                                         LocalDateTime outDate,
                                                                         Integer actualAmountDue) {
        if (Objects.isNull(studentRecordId)) {
            throw new RuntimeException("学籍ID为空！");
        }
        if (Objects.isNull(clazzId)) {
            throw new RuntimeException("班级ID为空！");
        }
        if (Objects.isNull(afterDate)) {
            throw new RuntimeException("开班时间为空！");
        }
        if (Objects.isNull(inDate)) {
            throw new RuntimeException("进班时间为空！");
        }
        return new StudentRecordChangeWithClazzStartDateDTO(
                studentRecordId,
                clazzId,
                clazzName,
                afterDate,
                inDate,
                outDate,
                actualAmountDue
        );
    }


    private StudentRecordChangeWithClazzStartDateDTO(String studentRecordId,
                                                     Integer clazzId,
                                                     String clazzName,
                                                     LocalDateTime afterDate,
                                                     LocalDateTime inDate,
                                                     LocalDateTime outDate,
                                                     Integer actualAmountDue) {
        this.studentRecordId = studentRecordId;
        this.clazzId = clazzId;
        this.clazzName = clazzName;
        this.afterDate = afterDate ;
        this.inDate = inDate;
        this.outDate = outDate;
        this.actualAmountDue = actualAmountDue;
    }
}
